﻿<%@ Page CodeFileBaseClass="AliCMS.Lib.MultiUserAdminPageBase" %>
<ali:List ID="ModuleTable" Mark="System" Object="Module" />
<ali:List ID="Bindings" Object="Channel.Binding" Condition="ChannelID=Request.QueryString['ChannelID']" />
<script language="c#" runat="server">
protected string GetModuleName(DataRow record)
{
	DataRow[] rows = ModuleTable.Select(AliCMS.SystemModule.Alias.Module.Namespace + "='" + record[AliCMS.SystemModule.Alias.Template.Module.ModuleID] + "'");
	if( rows.Length != 0)
		return rows[0][AliCMS.SystemModule.Alias.Module.Label].ToString();
	else
		return String.Empty;
}

protected string GetEditData(object mark)
{
	if (String.IsNullOrEmpty(Request.QueryString["ChannelID"]))
		return " data-id=\"\"";
	
	DataRow[] rows = Bindings.Select(Alias.Channel.Binding.Mark + "='" + mark + "'");
	if (rows.Length > 0)
	{
		return " data-id=\"" + rows[0][Alias.Channel.Binding.InnerID] + "\" data-old-binding-instance-id=\"" + rows[0][Alias.Channel.Binding.BindingInstanceID] + "\" data-old-binding-sub-instance-id=\"" + rows[0][Alias.Channel.Binding.BindingSubInstanceID] + "\" data-old-binding-channel-id=\"" + rows[0][Alias.Channel.Binding.BindingChannelID] + "\"";
	}

	return " data-id=\"\"";
}
</script>
<ali:List Mark="System" Object="Template.Module" Condition="TemplatePath=Request.QueryString['TemplatePath']">
	<table class="sub-list-table">
		<ali:Record>
			<%If Convert.ToString(Mark) != ""%>
				<tr<%=GetEditData(Mark)%> data-mark="<%=Mark%>" data-namespace="<%=ModuleID%>" data-just-data="<%=JustData%>">
					<th><%=Mark%>(<%=GetModuleName(Record)%>)</th>
					<td></td>
				</tr>
			<%EndIf%>
		</ali:Record>
	</table>
</ali:List>
